package com.hmall.item.config;

import com.hmall.item.constatnts.MqConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mq配置类
 */
@Configuration
public class MqConfig {

    //定义交换机
    @Bean
    public DirectExchange directExchange(){
        return ExchangeBuilder.directExchange("down_or_up_exchange").build();
    }


    //定义队列
    @Bean
    public Queue directQueue(){
        return new Queue("down_or_up_queue");
    }


    //绑定队列到交换机中
    @Bean
    public Binding directBinding(){
        return BindingBuilder.bind(directQueue()).to(directExchange()).with("downOrUp");
    }

}
